//全局变量
var order_status = 2;
var page = 1;
var searchParam = {
	page: 1,
	status:2
};
var list = [];
var count = 0;
var object = {};
var str = location.href; //取得整个地址栏
//var str = "https://www.900yeah.com/index.php/api/Orderdetailed/index?id=206&mobile=18511175959"
console.log(str)
var num = str.indexOf("?")
str = str.substr(num + 1); //取得所有参数   stringvar.substr(start [, length ]

var arr = str.split("&"); //各个参数放到数组里
for(var i = 0; i < arr.length; i++) {
	object[arr[i].split("=")[0]] = arr[i].split("=")[1]
}
searchParam.id = object.id;
searchParam.mobile = object.mobile;
console.log(searchParam)
// 复制
	
// 跳转详情
function btn_1(res) {
	console.log("---跳转详情页---");
	console.log(res)
	location.href = "./details.html?id="+ searchParam.id +"&mobile="+ searchParam.mobile +"&order_sn=" + res.id
}
// 跳转物流
function cha(res) {
	console.log("---跳转详情页---");
	console.log(res)
	location.href = "./logistics.html?id="+ searchParam.id +"&mobile="+ searchParam.mobile +"&logistics=" + res.id
}
// 录入物流信息
function logistics(res) {
	var bh = $("body").height();
	var bw = $("body").width();
	$(".bg").css({
// 		height: bh,
// 		width: bw,
		display: "block"
	});
	$(".logistics").show();
	var type = 0;
	if(res.name == 1) {
		type = 1
	} else if(res.name == 2) {
		type = 2
	}
	console.log(type)
	$.ajax({
		type: "POST",
		url: "https://www.900yeah.com/api/Orderdetailed/logisticslist",
		dataType: "json",
		data: {
			"id": searchParam.id,
			"mobile": searchParam.mobile,
			"order_sn": res.id,
			"type": type
		},
		success: function(res) {
			console.log(res);
			var data = res.result;
			console.log(data)
			var str = '';
			var str_n = "";

			str += '<div class="logistics_list">'
			str += '<div>'
			str += '<p>' + '姓名：' + '</p>' + '<p id="tar_text">' + data.user_name + '</p>'
			str += '<button id="copy" data-clipboard-action="copy" data-clipboard-target="#tar_text">' + '复制' + '</button>'
			str += '</div>'
			str += '<div>'
			str += '<p>' + '电话：' + '<p id="tar_text1">' + data.user_mobile + '</p>' + '</p>'
			str += '<button id="copy1" data-clipboard-action="copy" data-clipboard-target="#tar_text1">' + '复制' + '</button>'
			str += '</div>'
			str += '<div>'
			str += '<p>' + '地址：' + '</p>' + '<p id="tar_text2">' + data.region + '</p>'
			str += '<button id="copy2" data-clipboard-action="copy" data-clipboard-target="#tar_text2">' + '复制' + '</button>'
			str += '</div>'
			str += '</div>'
			str += '<div class="logistics_message">'
			str += '<p>' + '德邦物流' + '</p>'
			str += '<div>'
			str += '<input type="number" name="' + data.order_sn + '" id="orderNumber" value="' + data.logistics + '" placeholder="输入快递单号" />'
			str += '<img src="https://www.900yeah.com/static/Api/images/saoma.png" />'
			str += '</div>'
			str += '</div>'
			$(".logistics_list_div").html("");
			$(".logistics_list_div").append(str);
		},
		error: function(res) {
			console.log(res)
		}
	});

}
//修改/添加
function confirm() {
	var logistics = $("#orderNumber").val();
	var order_sn = $("#orderNumber").attr("name");
	console.log(logistics);
	console.log(order_sn);
	if(logistics != ""){

        $.ajax({
            type: "POST",
            url: "https://www.900yeah.com/api/Orderdetailed/logisticsadd",
            dataType: "json",
            data: {
                "id": searchParam.id,
                "mobile": searchParam.mobile,
                "order_sn": order_sn,
                "logistics": logistics
            },
            success: function(res) {
                console.log(res);
                location.reload();
            },
            error: function(res) {
                console.log(res)
            }
        });
	}else{
        alert("请输入物流单号！")
    }

}
//关闭弹框
function No() {
	$(".bg,.logistics").hide();
}
// tab 切换
$('li').click(function() {
	var index = $(this).index();
	$('li').eq(index).addClass('active').siblings().removeClass('active');
	$('.content').eq(index).show().siblings().hide();
});
// 进来默认待配送
$(document).ready(function() {
	var clipboard = new ClipboardJS('#copy');
	var clipboard = new ClipboardJS('#copy1');
	var clipboard = new ClipboardJS('#copy2');
	var clipboard = new ClipboardJS('#copy3');
	var clipboard = new ClipboardJS('#copy4');
	var clipboard = new ClipboardJS('#copy5');
	var clipboard = new ClipboardJS('#copy6');
	var clipboard = new ClipboardJS('#copy7');
	var clipboard = new ClipboardJS('#copy8');
	var clipboard = new ClipboardJS('#copy9');
	var clipboard = new ClipboardJS('#copy10');
	$(".null").hide();
	console.log(searchParam)
	$.ajax({
		type: "POST",
		url: "https://www.900yeah.com/api/Orderdetailed/indexlist",
		dataType: "json",
		data: {
			"id": searchParam.id,
			"mobile": searchParam.mobile,
			"status": 2
		},
		success: function(res) {
			console.log(res);
			var data = res.result.list;
			var str = '';
			var str_n = "";
			if(res.result.length == 0) {
				$(".null").show();
				$(".content").html("");
			} else {
				$(".null").hide();
				count = res.result.count;
				list = data;
				$.each(data, function(i, u) {
					console.log(i);
					console.log(u);
					str += '<div class="await">';
					str += '<div class="await_title">';
					str += '<div class="await_title_left">';
					str += '<p>' + '订单号码：' + u.order_sn + '</p>';
					str += '<p>' + '下单时间：' + u.create_time + '</p>';
					str += '</div>';
					str += '<div class="await_title_right">';
					str += '待配送';
					str += '</div>';
					str += '</div>';
					str += '<div class="await_list" onclick="btn_1(this)" id="'+ u.order_sn +'">';
					u.sum = 0;
					$.each(u.shoppingcart, function(index, element) {
						str += '<div>';
						if(element.label == 4) {
							str += '	<p>' + element.comm_name + element.type + 'ml * ' + element.label + '瓶' + '</p>';
							str += '	<p>' + '一盒装' + 'x' + element.num + '</p>';
						}
						if(element.label == 6) {
							str += '	<p>' + element.comm_name + element.type + 'ml * ' + element.label + '瓶' + '</p>';
							str += '	<p>' + '一箱装' + 'x' + element.num + '</p>';
						}
						if(element.label == 10) {
							str += '	<p>' + element.comm_name + element.type + 'ml * ' + element.label + '瓶' + '</p>';
							str += '	<p>' + '一提装' + 'x' + element.num + '</p>';
						}
						if(element.label == 40) {
							str += '	<p>' + element.comm_name + element.type + 'ml * ' + element.label + '瓶' + '</p>';
							str += '	<p>' + '一箱装' + 'x' + element.num + '</p>';
						}
						str += '</div>';
						u.sum += parseInt(element.num);
					});
					str += '</div>'
					str += '<div class="distribution_num">';
					str += '<p>' + '共' + u.sum + '件' + '</p>';
					str += '<button style="background: #E50012;color: #fff;" onclick="logistics(this)" name="1" id="' + u.order_sn +
						'">' + '录入配送信息' + '</button>';
					str += '</div>';
					str += '<div class="logistics_list">';
					str += '<div>';
					str += '<p>' + '姓名：' + '<p id="tar_' + u.order_id + '">' + u.user_name + '</p>' + '</p>';
					str += '<button id="copy3" data-clipboard-action="copy" data-clipboard-target="#tar_' + u.order_id + '">' +
						'复制' +
						'</button>';
					str += '</div>';
					str += '<div>';
					str += '<p>' + '电话：' + '<p id="ter_' + u.order_id + '">' + u.user_mobile + '</p>' + '</p>';
					str += '<button id="copy4" data-clipboard-action="copy" data-clipboard-target="#ter_' + u.order_id + '">' +
						'复制' +
						'</button>';
					str += '</div>';
					str += '<div>';
					str += '<p>' + '地址：' + '<p id="tdr_' + u.order_id + '">' + u.region + '</p>' + '</p>';
					str += '<button id="copy5" data-clipboard-action="copy" data-clipboard-target="#tdr_' + u.order_id + '">' +
						'复制' +
						'</button>';
					str += '</div>';
					str += '</div>';
					str += '</div>';
				});
				$(".content").append(str);
			}
		},
		error: function(res) {
			console.log(res)
		}
	});
});

//全部订单
function allOrder(res) {
	// $("#search").val("");
	var status = res.id.substr(4, 1);
	console.log(status)
	var data = searchParam;
	if(status != 0) {
		data.status = parseInt(status);
	}else{
		delete data.status;
	}
	data.page = 1;
	searchParam = data;
	// data = JSON.stringify(data);
	order_status = status
	console.log(data)
	$.ajax({
		type: "POST",
		url: "https://www.900yeah.com/api/Orderdetailed/indexlist",
		dataType: "json",
		data: data,
		success: function(res) {
			console.log(res);
			var data = res.result.list;
			var str = '';
			var str_n = "";
			if(res.result.length == 0) {
				$(".null").show();
			} else {
				$(".null").hide();
				count = res.result.count;
				list = data;
				$.each(data, function(i, u) {
					if(u.order_status == "1") {
						str += '<div class="await">';
						str += '<div class="await_title_1">';
						str += '<div class="await_title_left">';
						str += '<p>' + '订单号码：' + u.order_sn + '</p>';
						str += '<p>' + '下单时间：' + u.create_time + '</p>';
						str += '</div>';
						str += '<div class="await_title_right">';
						str += '未支付';
						str += '</div>';
						str += '</div>';
						str += '<div class="await_list" onclick="btn_1(this)" id="'+ u.order_sn +'">';
						u.sum = 0;
						$.each(u.shoppingcart, function(index, element) {
							str += '	<div>';
							if(element.label == 4) {
								str += '	<p>' + element.comm_name + element.type + 'ml * ' + element.label + '瓶' + '</p>';
								str += '	<p>' + '一盒装' + 'x' + element.num + '</p>';
							}
							if(element.label == 6) {
								str += '	<p>' + element.comm_name + element.type + 'ml * ' + element.label + '瓶' + '</p>';
								str += '	<p>' + '一箱装' + 'x' + element.num + '</p>';
							}
							if(element.label == 10) {
								str += '	<p>' + element.comm_name + element.type + 'ml * ' + element.label + '瓶' + '</p>';
								str += '	<p>' + '一提装' + 'x' + element.num + '</p>';
							}
							if(element.label == 40) {
								str += '	<p>' + element.comm_name + element.type + 'ml * ' + element.label + '瓶' + '</p>';
								str += '	<p>' + '一箱装' + 'x' + element.num + '</p>';
							}
							str += '	</div>';
							u.sum += parseInt(element.num);
						});
						str += '</div>'
						str += '<div class="distribution_num">';
						str += '<p>' + '共' + u.sum + '件' + '</p>';
						str += '</div>';
						str += '</div>';
					}
					if(u.order_status == "2") {
						str += '<div class="await">';
						str += '<div class="await_title">';
						str += '<div class="await_title_left">';
						str += '<p>' + '订单号码：' + u.order_sn + '</p>';
						str += '<p>' + '下单时间：' + u.create_time + '</p>';
						str += '</div>';
						str += '<div class="await_title_right">';
						str += '待配送';
						str += '</div>';
						str += '</div>';
						str += '<div class="await_list" onclick="btn_1(this)" id="'+ u.order_sn +'">';
						u.sum = 0
						$.each(u.shoppingcart, function(index, element) {
							str += '	<div>';
							if(element.label == 4) {
								str += '	<p>' + element.comm_name + element.type + 'ml * ' + element.label + '瓶' + '</p>';
								str += '	<p>' + '一盒装' + 'x' + element.num + '</p>';
							}
							if(element.label == 6) {
								str += '	<p>' + element.comm_name + element.type + 'ml * ' + element.label + '瓶' + '</p>';
								str += '	<p>' + '一箱装' + 'x' + element.num + '</p>';
							}
							if(element.label == 10) {
								str += '	<p>' + element.comm_name + element.type + 'ml * ' + element.label + '瓶' + '</p>';
								str += '	<p>' + '一提装' + 'x' + element.num + '</p>';
							}
							if(element.label == 40) {
								str += '	<p>' + element.comm_name + element.type + 'ml * ' + element.label + '瓶' + '</p>';
								str += '	<p>' + '一箱装' + 'x' + element.num + '</p>';
							}
							str += '	</div>';
							u.sum += parseInt(element.num);
						});
						str += '</div>'
						str += '<div class="distribution_num">';
						str += '<p>' + '共' + u.sum + '件' + '</p>';
						str += '<button style="background: #E50012;color: #fff;" onclick="logistics(this)" name="1" id="' + u.order_sn +
							'">' + '录入配送信息' + '</button>';
						str += '</div>';
						str += '<div class="logistics_list">';
						str += '<div>';
						str += '<p>' + '姓名：' + '<p id="tar_' + u.order_id + '">' + u.user_name + '</p>' + '</p>';
						str += '<button id="copy6" data-clipboard-action="copy" data-clipboard-target="#tar_' + u.order_id + '">' +
							'复制' +
							'</button>';
						str += '</div>';
						str += '<div>';
						str += '<p>' + '电话：' + '<p id="ter_' + u.order_id + '">' + u.user_mobile + '</p>' + '</p>';
						str += '<button id="copy7" data-clipboard-action="copy" data-clipboard-target="#ter_' + u.order_id + '">' +
							'复制' +
							'</button>';
						str += '</div>';
						str += '<div>';
						str += '<p>' + '地址：' + '<p id="tdr_' + u.order_id + '">' + u.region + '</p>' + '</p>';
						str += '<button id="copy8" data-clipboard-action="copy" data-clipboard-target="#tdr_' + u.order_id + '">' +
							'复制' +
							'</button>';
						str += '</div>';
						str += '</div>';
						str += '</div>';
					}
					if(u.order_status == "5") {
						str += '<div class="distribution">'
						str += '<div class="distribution_title">'
						str += '<div class="distribution_title_left">'
						str += '<p>' + '订单号码：' + u.order_sn + '</p>'
						str += '<p>' + '下单时间：' + u.create_time + '</p>'
						str += '</div>'
						str += '<div class="distribution_title_right">'
						str += '配送中'
						str += '</div>'
						str += '</div>'
						str += '<div class="distribution_list" onclick="btn_1(this)" id="'+ u.order_sn +'">'
						u.sum = 0
						$.each(u.shoppingcart, function(index, element) {
							str += '	<div>';
							if(element.label == 4) {
								str += '	<p>' + element.comm_name + element.type + 'ml * ' + element.label + '瓶' + '</p>';
								str += '	<p>' + '一盒装' + 'x' + element.num + '</p>';
							}
							if(element.label == 6) {
								str += '	<p>' + element.comm_name + element.type + 'ml * ' + element.label + '瓶' + '</p>';
								str += '	<p>' + '一箱装' + 'x' + element.num + '</p>';
							}
							if(element.label == 10) {
								str += '	<p>' + element.comm_name + element.type + 'ml * ' + element.label + '瓶' + '</p>';
								str += '	<p>' + '一提装' + 'x' + element.num + '</p>';
							}
							if(element.label == 40) {
								str += '	<p>' + element.comm_name + element.type + 'ml * ' + element.label + '瓶' + '</p>';
								str += '	<p>' + '一箱装' + 'x' + element.num + '</p>';
							}
							str += '	</div>';
							u.sum += parseInt(element.num);
						});
						str += '</div>'
						str += '<div class="distribution_num">'
						str += '<p>' + '共' + u.sum + '件' + '</p>'
						str += '<button onclick="cha(this)" id="'+ u.logistics +'">' + '查看物流' + '</button>'
						str += '</div>'
						str += '<div class="distribution_express">'
						str += '<p>' + '德邦物流：' + '<span id="tar_' + u.order_id + '">' + u.logistics + '</span>' + '</p>'
						str += '<div>'
						str += '<button name="2" onclick="logistics(this)" id="' + u.order_sn + '">' + '修改' + '</button>'
						str += '<button id="copy9" data-clipboard-action="copy" data-clipboard-target="#tar_' + u.order_id + '">' +
							'复制' +
							'</button>'
						str += '</div>'
						str += '</div>'
						str += '</div>'
					}
					if(u.order_status == "4") {
						str += '<div class="await">';
						str += '<div class="await_title_2">';
						str += '<div class="await_title_left">';
						str += '<p>' + '订单号码：' + u.order_sn + '</p>';
						str += '<p>' + '下单时间：' + u.create_time + '</p>';
						str += '</div>';
						str += '<div class="await_title_right">';
						str += '已取消';
						str += '</div>';
						str += '</div>';
						str += '<div class="await_list" onclick="btn_1(this)" id="'+ u.order_sn +'">';
						u.sum = 0
						$.each(u.shoppingcart, function(index, element) {
							str += '	<div>';
							if(element.label == 4) {
								str += '	<p>' + element.comm_name + element.type + 'ml * ' + element.label + '瓶' + '</p>';
								str += '	<p>' + '一盒装' + 'x' + element.num + '</p>';
							}
							if(element.label == 6) {
								str += '	<p>' + element.comm_name + element.type + 'ml * ' + element.label + '瓶' + '</p>';
								str += '	<p>' + '一箱装' + 'x' + element.num + '</p>';
							}
							if(element.label == 10) {
								str += '	<p>' + element.comm_name + element.type + 'ml * ' + element.label + '瓶' + '</p>';
								str += '	<p>' + '一提装' + 'x' + element.num + '</p>';
							}
							if(element.label == 40) {
								str += '	<p>' + element.comm_name + element.type + 'ml * ' + element.label + '瓶' + '</p>';
								str += '	<p>' + '一箱装' + 'x' + element.num + '</p>';
							}
							str += '	</div>';
							u.sum += parseInt(element.num);
						});
						str += '</div>'
						str += '<div class="distribution_num">';
						str += '<p>' + '共' + u.sum + '件' + '</p>';
						str += '</div>';
						str += '</div>';
					}
					if(u.order_status == "3") {
						str += '<div class="accomplish">'
						str += '<div class="accomplish_title">'
						str += '<div class="accomplish_title_left">'
						str += '<p>' + '订单号码：' + u.order_sn + '</p>'
						str += '<p>' + '下单时间：' + u.create_time + '</p>'
						str += '</div>'
						str += '<div class="accomplish_title_right">'
						str += '已完成'
						str += '</div>'
						str += '</div>'
						str += '<div class="accomplish_list" onclick="btn_1(this)" id="'+ u.order_sn +'">'
						u.sum = 0
						$.each(u.shoppingcart, function(index, element) {
							str += '	<div>';
							if(element.label == 4) {
								str += '	<p>' + element.comm_name + element.type + 'ml * ' + element.label + '瓶' + '</p>';
								str += '	<p>' + '一盒装' + 'x' + element.num + '</p>';
							}
							if(element.label == 6) {
								str += '	<p>' + element.comm_name + element.type + 'ml * ' + element.label + '瓶' + '</p>';
								str += '	<p>' + '一箱装' + 'x' + element.num + '</p>';
							}
							if(element.label == 10) {
								str += '	<p>' + element.comm_name + element.type + 'ml * ' + element.label + '瓶' + '</p>';
								str += '	<p>' + '一提装' + 'x' + element.num + '</p>';
							}
							if(element.label == 40) {
								str += '	<p>' + element.comm_name + element.type + 'ml * ' + element.label + '瓶' + '</p>';
								str += '	<p>' + '一箱装' + 'x' + element.num + '</p>';
							}
							str += '	</div>';
							u.sum += parseInt(element.num);
						});
						str += '</div>'
						str += '<div class="accomplish_num">'
						str += '<p>' + '共' + u.sum + '件' + '</p>'
						str += '<button onclick="cha(this)" id="'+ u.logistics +'">' + '查看物流' + '</button>'
						str += '</div>'
						str += '<div class="accomplish_express">'
						str += '<p>' + '德邦物流：' + '<span id="tar_' + u.order_id + '">' + u.logistics + '</span>' + '</p>'
						str += '<button id="copy10" data-clipboard-action="copy" data-clipboard-target="#tar_' + u.order_id + '">' +
							'复制' +
							'</button>'
						str += '</div>'
						str += '</div>'
					}
				});
			}
			$(".content").html("");
			$(".content").append(str);
		},
		error: function(res) {
			console.log(res)
		}
	});
}

//搜索
function search(res) {
	var param = searchParam;
	param.name = res.value;
	console.log(param)
	$.ajax({
		type: "POST",
		url: "https://www.900yeah.com/api/Orderdetailed/indexlist",
		dataType: "json",
		data: param,
		success: function(res) {
			var data = res.result.list;
			console.log(res)
			var str = '';
			var str_n = "";
			if(res.result.length == 0) {
				$(".null").show();
				$(".content").html("");
			} else {
				$(".null").hide();
				count = res.result.count;
				$.each(data, function(i, u) {
					if(u.order_status == "1") {
						str += '<div class="await">';
						str += '<div class="await_title_1">';
						str += '<div class="await_title_left">';
						str += '<p>' + '订单号码：' + u.order_sn + '</p>';
						str += '<p>' + '下单时间：' + u.create_time + '</p>';
						str += '</div>';
						str += '<div class="await_title_right">';
						str += '未支付';
						str += '</div>';
						str += '</div>';
						str += '<div class="await_list" onclick="btn_1(this)" id="'+ u.order_sn +'">';
						u.sum = 0;
						$.each(u.shoppingcart, function(index, element) {
							str += '	<div>';
							if(element.label == 4) {
								str += '	<p>' + element.comm_name + element.type + 'ml * ' + element.label + '瓶' + '</p>';
								str += '	<p>' + '一盒装' + 'x' + element.num + '</p>';
							}
							if(element.label == 6) {
								str += '	<p>' + element.comm_name + element.type + 'ml * ' + element.label + '瓶' + '</p>';
								str += '	<p>' + '一箱装' + 'x' + element.num + '</p>';
							}
							if(element.label == 10) {
								str += '	<p>' + element.comm_name + element.type + 'ml * ' + element.label + '瓶' + '</p>';
								str += '	<p>' + '一提装' + 'x' + element.num + '</p>';
							}
							if(element.label == 40) {
								str += '	<p>' + element.comm_name + element.type + 'ml * ' + element.label + '瓶' + '</p>';
								str += '	<p>' + '一箱装' + 'x' + element.num + '</p>';
							}
							str += '	</div>';
							u.sum += parseInt(element.num);
						});
						str += '</div>'
						str += '<div class="distribution_num">';
						str += '<p>' + '共' + u.sum + '件' + '</p>';
						str += '</div>';
						str += '</div>';
					}
					if(u.order_status == "2") {

						str += '<div class="await">';
						str += '<div class="await_title">';
						str += '<div class="await_title_left">';
						str += '<p>' + '订单号码：' + u.order_sn + '</p>';
						str += '<p>' + '下单时间：' + u.create_time + '</p>';
						str += '</div>';
						str += '<div class="await_title_right">';
						str += '待配送';
						str += '</div>';
						str += '</div>';
						str += '<div class="await_list" onclick="btn_1(this)" id="'+ u.order_sn +'">';
						u.sum = 0
						$.each(u.shoppingcart, function(index, element) {
							str += '	<div>';
							if(element.label == 4) {
								str += '	<p>' + element.comm_name + element.type + 'ml * ' + element.label + '瓶' + '</p>';
								str += '	<p>' + '一盒装' + 'x' + element.num + '</p>';
							}
							if(element.label == 6) {
								str += '	<p>' + element.comm_name + element.type + 'ml * ' + element.label + '瓶' + '</p>';
								str += '	<p>' + '一箱装' + 'x' + element.num + '</p>';
							}
							if(element.label == 10) {
								str += '	<p>' + element.comm_name + element.type + 'ml * ' + element.label + '瓶' + '</p>';
								str += '	<p>' + '一提装' + 'x' + element.num + '</p>';
							}
							if(element.label == 40) {
								str += '	<p>' + element.comm_name + element.type + 'ml * ' + element.label + '瓶' + '</p>';
								str += '	<p>' + '一箱装' + 'x' + element.num + '</p>';
							}
							str += '	</div>';
							u.sum += parseInt(element.num);
						});
						str += '</div>'
						str += '<div class="distribution_num">';
						str += '<p>' + '共' + u.sum + '件' + '</p>';
						str += '<button style="background: #E50012;color: #fff;" onclick="logistics(this)" name="1" id="' + u.order_sn +
							'">' + '录入配送信息' + '</button>';
						str += '</div>';
						str += '<div class="logistics_list">';
						str += '<div>';
						str += '<p>' + '姓名：' + '<p id="tar_' + u.order_id + '">' + u.user_name + '</p>' + '</p>';
						str += '<button id="copy6" data-clipboard-action="copy" data-clipboard-target="#tar_' + u.order_id + '">' +
							'复制' +
							'</button>';
						str += '</div>';
						str += '<div>';
						str += '<p>' + '电话：' + '<p id="ter_' + u.order_id + '">' + u.user_mobile + '</p>' + '</p>';
						str += '<button id="copy7" data-clipboard-action="copy" data-clipboard-target="#ter_' + u.order_id + '">' +
							'复制' +
							'</button>';
						str += '</div>';
						str += '<div>';
						str += '<p>' + '地址：' + '<p id="tdr_' + u.order_id + '">' + u.region + '</p>' + '</p>';
						str += '<button id="copy8" data-clipboard-action="copy" data-clipboard-target="#tdr_' + u.order_id + '">' +
							'复制' +
							'</button>';
						str += '</div>';
						str += '</div>';
						str += '</div>';
					}
					if(u.order_status == "5") {
						str += '<div class="distribution">'
						str += '<div class="distribution_title">'
						str += '<div class="distribution_title_left">'
						str += '<p>' + '订单号码：' + u.order_sn + '</p>'
						str += '<p>' + '下单时间：' + u.create_time + '</p>'
						str += '</div>'
						str += '<div class="distribution_title_right">'
						str += '配送中'
						str += '</div>'
						str += '</div>'
						str += '<div class="distribution_list" onclick="btn_1(this)" id="'+ u.order_sn +'">'
						u.sum = 0
						$.each(u.shoppingcart, function(index, element) {
							str += '	<div>';
							if(element.label == 4) {
								str += '	<p>' + element.comm_name + element.type + 'ml * ' + element.label + '瓶' + '</p>';
								str += '	<p>' + '一盒装' + 'x' + element.num + '</p>';
							}
							if(element.label == 6) {
								str += '	<p>' + element.comm_name + element.type + 'ml * ' + element.label + '瓶' + '</p>';
								str += '	<p>' + '一箱装' + 'x' + element.num + '</p>';
							}
							if(element.label == 10) {
								str += '	<p>' + element.comm_name + element.type + 'ml * ' + element.label + '瓶' + '</p>';
								str += '	<p>' + '一提装' + 'x' + element.num + '</p>';
							}
							if(element.label == 40) {
								str += '	<p>' + element.comm_name + element.type + 'ml * ' + element.label + '瓶' + '</p>';
								str += '	<p>' + '一箱装' + 'x' + element.num + '</p>';
							}
							str += '	</div>';
							u.sum += parseInt(element.num);
						});
						str += '</div>'
						str += '<div class="distribution_num">'
						str += '<p>' + '共' + u.sum + '件' + '</p>'
						str += '<button onclick="cha(this)" id="'+ u.logistics +'">' + '查看物流' + '</button>'
						str += '</div>'
						str += '<div class="distribution_express">'
						str += '<p>' + '德邦物流：' + '<span id="tar_' + u.order_id + '">' + u.logistics + '</span>' + '</p>'
						str += '<div>'
						str += '<button name="2" onclick="logistics(this)" id="' + u.order_sn + '">' + '修改' + '</button>'
						str += '<button id="copy9" data-clipboard-action="copy" data-clipboard-target="#tar_' + u.order_id + '">' +
							'复制' +
							'</button>'
						str += '</div>'
						str += '</div>'
						str += '</div>'
					}
					if(u.order_status == "4") {
						str += '<div class="await">';
						str += '<div class="await_title_2">';
						str += '<div class="await_title_left">';
						str += '<p>' + '订单号码：' + u.order_sn + '</p>';
						str += '<p>' + '下单时间：' + u.create_time + '</p>';
						str += '</div>';
						str += '<div class="await_title_right">';
						str += '已取消';
						str += '</div>';
						str += '</div>';
						str += '<div class="await_list" onclick="btn_1(this)" id="'+ u.order_sn +'">';
						u.sum = 0
						$.each(u.shoppingcart, function(index, element) {
							str += '	<div>';
							if(element.label == 4) {
								str += '	<p>' + element.comm_name + element.type + 'ml * ' + element.label + '瓶' + '</p>';
								str += '	<p>' + '一盒装' + 'x' + element.num + '</p>';
							}
							if(element.label == 6) {
								str += '	<p>' + element.comm_name + element.type + 'ml * ' + element.label + '瓶' + '</p>';
								str += '	<p>' + '一箱装' + 'x' + element.num + '</p>';
							}
							if(element.label == 10) {
								str += '	<p>' + element.comm_name + element.type + 'ml * ' + element.label + '瓶' + '</p>';
								str += '	<p>' + '一提装' + 'x' + element.num + '</p>';
							}
							if(element.label == 40) {
								str += '	<p>' + element.comm_name + element.type + 'ml * ' + element.label + '瓶' + '</p>';
								str += '	<p>' + '一箱装' + 'x' + element.num + '</p>';
							}
							str += '	</div>';
							u.sum += parseInt(element.num);
						});
						str += '</div>'
						str += '<div class="distribution_num">';
						str += '<p>' + '共' + u.sum + '件' + '</p>';
						str += '</div>';
						str += '</div>';
					}
					if(u.order_status == "3") {
						str += '<div class="accomplish">'
						str += '<div class="accomplish_title">'
						str += '<div class="accomplish_title_left">'
						str += '<p>' + '订单号码：' + u.order_sn + '</p>'
						str += '<p>' + '下单时间：' + u.create_time + '</p>'
						str += '</div>'
						str += '<div class="accomplish_title_right">'
						str += '已完成'
						str += '</div>'
						str += '</div>'
						str += '<div class="accomplish_list" onclick="btn_1(this)" id="'+ u.order_sn +'">'
						u.sum = 0
						$.each(u.shoppingcart, function(index, element) {
							str += '	<div>';
							if(element.label == 4) {
								str += '	<p>' + element.comm_name + element.type + 'ml * ' + element.label + '瓶' + '</p>';
								str += '	<p>' + '一盒装' + 'x' + element.num + '</p>';
							}
							if(element.label == 6) {
								str += '	<p>' + element.comm_name + element.type + 'ml * ' + element.label + '瓶' + '</p>';
								str += '	<p>' + '一箱装' + 'x' + element.num + '</p>';
							}
							if(element.label == 10) {
								str += '	<p>' + element.comm_name + element.type + 'ml * ' + element.label + '瓶' + '</p>';
								str += '	<p>' + '一提装' + 'x' + element.num + '</p>';
							}
							if(element.label == 40) {
								str += '	<p>' + element.comm_name + element.type + 'ml * ' + element.label + '瓶' + '</p>';
								str += '	<p>' + '一箱装' + 'x' + element.num + '</p>';
							}
							str += '	</div>';
							u.sum += parseInt(element.num);
						});
						str += '</div>'
						str += '<div class="accomplish_num">'
						str += '<p>' + '共' + u.sum + '件' + '</p>'
						str += '<button onclick="cha(this)" id="'+ u.logistics +'">' + '查看物流' + '</button>'
						str += '</div>'
						str += '<div class="accomplish_express">'
						str += '<p>' + '德邦物流：' + '<span id="tar_' + u.order_id + '">' + u.logistics + '</span>' + '</p>'
						str += '<button id="copy10" data-clipboard-action="copy" data-clipboard-target="#tar_' + u.order_id + '">' +
							'复制' +
							'</button>'
						str += '</div>'
						str += '</div>'
					}
				});
				$(".content").html("");
				$(".content").append(str);
			}
		},
		error: function(res) {
			console.log(res)
		},
	})
}

//--------------上拉加载更多---------------
//获取滚动条当前的位置 
function getScrollTop() {
	var scrollTop = 0;
	if(document.documentElement && document.documentElement.scrollTop) {
		scrollTop = document.documentElement.scrollTop;
	} else if(document.body) {
		scrollTop = document.body.scrollTop;
	}
	return scrollTop;
}

//获取当前可视范围的高度 
function getClientHeight() {
	var clientHeight = 0;
	if(document.body.clientHeight && document.documentElement.clientHeight) {
		clientHeight = Math.min(document.body.clientHeight, document.documentElement.clientHeight);
	} else {
		clientHeight = Math.max(document.body.clientHeight, document.documentElement.clientHeight);
	}
	return clientHeight;
}

//获取文档完整的高度 
function getScrollHeight() {
	return Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
}

//滚动事件触发
window.onscroll = function() {
	var param = searchParam;
	if(getScrollTop() + getClientHeight() == getScrollHeight()) {
		if(param.page < count) {
		$(".jiazai").css({
		display: "block"
	});
			param.page = Number(param.page) + Number(1);
			searchParam = param;
			console.log(param)
			$.ajax({
				type: "POST",
				url: "https://www.900yeah.com/api/Orderdetailed/indexlist",
				dataType: "json",
				data: param,
				success: function(res) {
					console.log(res)
					if(res.result.length != 0) {
						res.result.list.forEach(function(element) {
							list.push(element)
						});
						var str = '';
						var str_n = "";
						console.log(list)
						$.each(list, function(i, u) {
							if(u.order_status == "1") {
								str += '<div class="await">';
								str += '<div class="await_title_1">';
								str += '<div class="await_title_left">';
								str += '<p>' + '订单号码：' + u.order_sn + '</p>';
								str += '<p>' + '下单时间：' + u.create_time + '</p>';
								str += '</div>';
								str += '<div class="await_title_right">';
								str += '未支付';
								str += '</div>';
								str += '</div>';
								str += '<div class="await_list" onclick="btn_1(this)" id="'+ u.order_sn +'">';
								u.sum = 0;
								$.each(u.shoppingcart, function(index, element) {
									str += '	<div>';
									if(element.label == 4) {
										str += '	<p>' + element.comm_name + element.type + 'ml * ' + element.label + '瓶' + '</p>';
										str += '	<p>' + '一盒装' + 'x' + element.num + '</p>';
									}
									if(element.label == 6) {
										str += '	<p>' + element.comm_name + element.type + 'ml * ' + element.label + '瓶' + '</p>';
										str += '	<p>' + '一箱装' + 'x' + element.num + '</p>';
									}
									if(element.label == 10) {
										str += '	<p>' + element.comm_name + element.type + 'ml * ' + element.label + '瓶' + '</p>';
										str += '	<p>' + '一提装' + 'x' + element.num + '</p>';
									}
									if(element.label == 40) {
										str += '	<p>' + element.comm_name + element.type + 'ml * ' + element.label + '瓶' + '</p>';
										str += '	<p>' + '一箱装' + 'x' + element.num + '</p>';
									}
									str += '	</div>';
									u.sum += parseInt(element.num);
								});
								str += '</div>'
								str += '<div class="distribution_num">';
								str += '<p>' + '共' + u.sum + '件' + '</p>';
								str += '</div>';
								str += '</div>';
							}
							if(u.order_status == "2") {
								str += '<div class="await">';
								str += '<div class="await_title">';
								str += '<div class="await_title_left">';
								str += '<p>' + '订单号码：' + u.order_sn + '</p>';
								str += '<p>' + '下单时间：' + u.create_time + '</p>';
								str += '</div>';
								str += '<div class="await_title_right">';
								str += '待配送';
								str += '</div>';
								str += '</div>';
								str += '<div class="await_list" onclick="btn_1(this)" id="'+ u.order_sn +'">';
								u.sum = 0
								$.each(u.shoppingcart, function(index, element) {
									str += '	<div>';
									if(element.label == 4) {
										str += '	<p>' + element.comm_name + element.type + 'ml * ' + element.label + '瓶' + '</p>';
										str += '	<p>' + '一盒装' + 'x' + element.num + '</p>';
									}
									if(element.label == 6) {
										str += '	<p>' + element.comm_name + element.type + 'ml * ' + element.label + '瓶' + '</p>';
										str += '	<p>' + '一箱装' + 'x' + element.num + '</p>';
									}
									if(element.label == 10) {
										str += '	<p>' + element.comm_name + element.type + 'ml * ' + element.label + '瓶' + '</p>';
										str += '	<p>' + '一提装' + 'x' + element.num + '</p>';
									}
									if(element.label == 40) {
										str += '	<p>' + element.comm_name + element.type + 'ml * ' + element.label + '瓶' + '</p>';
										str += '	<p>' + '一箱装' + 'x' + element.num + '</p>';
									}
									str += '	</div>';
									u.sum += parseInt(element.num);
								});
								str += '</div>'
								str += '<div class="distribution_num">';
								str += '<p>' + '共' + u.sum + '件' + '</p>';
								str += '<button style="background: #E50012;color: #fff;" onclick="logistics(this)" name="1" id="' + u.order_sn +
									'">' + '录入配送信息' + '</button>';
								str += '</div>';
								str += '<div class="logistics_list">';
								str += '<div>';
								str += '<p>' + '姓名：' + '<p id="tar_' + u.order_id + '">' + u.user_name + '</p>' + '</p>';
								str += '<button id="copy6" data-clipboard-action="copy" data-clipboard-target="#tar_' + u.order_id +
									'">' +
									'复制' +
									'</button>';
								str += '</div>';
								str += '<div>';
								str += '<p>' + '电话：' + '<p id="ter_' + u.order_id + '">' + u.user_mobile + '</p>' + '</p>';
								str += '<button id="copy7" data-clipboard-action="copy" data-clipboard-target="#ter_' + u.order_id +
									'">' +
									'复制' +
									'</button>';
								str += '</div>';
								str += '<div>';
								str += '<p>' + '地址：' + '<p id="tdr_' + u.order_id + '">' + u.region + '</p>' + '</p>';
								str += '<button id="copy8" data-clipboard-action="copy" data-clipboard-target="#tdr_' + u.order_id +
									'">' +
									'复制' +
									'</button>';
								str += '</div>';
								str += '</div>';
								str += '</div>';
							}
							if(u.order_status == "5") {
								str += '<div class="distribution">'
								str += '<div class="distribution_title">'
								str += '<div class="distribution_title_left">'
								str += '<p>' + '订单号码：' + u.order_sn + '</p>'
								str += '<p>' + '下单时间：' + u.create_time + '</p>'
								str += '</div>'
								str += '<div class="distribution_title_right">'
								str += '配送中'
								str += '</div>'
								str += '</div>'
								str += '<div class="distribution_list" onclick="btn_1(this)" id="'+ u.order_sn +'">'
								u.sum = 0
								$.each(u.shoppingcart, function(index, element) {
									str += '	<div>';
									if(element.label == 4) {
										str += '	<p>' + element.comm_name + element.type + 'ml * ' + element.label + '瓶' + '</p>';
										str += '	<p>' + '一盒装' + 'x' + element.num + '</p>';
									}
									if(element.label == 6) {
										str += '	<p>' + element.comm_name + element.type + 'ml * ' + element.label + '瓶' + '</p>';
										str += '	<p>' + '一箱装' + 'x' + element.num + '</p>';
									}
									if(element.label == 10) {
										str += '	<p>' + element.comm_name + element.type + 'ml * ' + element.label + '瓶' + '</p>';
										str += '	<p>' + '一提装' + 'x' + element.num + '</p>';
									}
									if(element.label == 40) {
										str += '	<p>' + element.comm_name + element.type + 'ml * ' + element.label + '瓶' + '</p>';
										str += '	<p>' + '一箱装' + 'x' + element.num + '</p>';
									}
									str += '	</div>';
									u.sum += parseInt(element.num);
								});
								str += '</div>'
								str += '<div class="distribution_num">'
								str += '<p>' + '共' + u.sum + '件' + '</p>'
								str += '<button onclick="cha(this)" id="'+ u.logistics +'">' + '查看物流' + '</button>'
								str += '</div>'
								str += '<div class="distribution_express">'
								str += '<p>' + '德邦物流：' + '<span id="tar_' + u.order_id + '">' + u.logistics + '</span>' + '</p>'
								str += '<div>'
								str += '<button name="2" onclick="logistics(this)" id="' + u.order_sn + '">' + '修改' + '</button>'
								str += '<button id="copy9" data-clipboard-action="copy" data-clipboard-target="#tar_' + u.order_id +
									'">' +
									'复制' +
									'</button>'
								str += '</div>'
								str += '</div>'
								str += '</div>'
							}
							if(u.order_status == "4") {
								str += '<div class="await">';
								str += '<div class="await_title_2">';
								str += '<div class="await_title_left">';
								str += '<p>' + '订单号码：' + u.order_sn + '</p>';
								str += '<p>' + '下单时间：' + u.create_time + '</p>';
								str += '</div>';
								str += '<div class="await_title_right">';
								str += '已取消';
								str += '</div>';
								str += '</div>';
								str += '<div class="await_list" onclick="btn_1(this)" id="'+ u.order_sn +'">';
								u.sum = 0
								$.each(u.shoppingcart, function(index, element) {
									str += '	<div>';
									if(element.label == 4) {
										str += '	<p>' + element.comm_name + element.type + 'ml * ' + element.label + '瓶' + '</p>';
										str += '	<p>' + '一盒装' + 'x' + element.num + '</p>';
									}
									if(element.label == 6) {
										str += '	<p>' + element.comm_name + element.type + 'ml * ' + element.label + '瓶' + '</p>';
										str += '	<p>' + '一箱装' + 'x' + element.num + '</p>';
									}
									if(element.label == 10) {
										str += '	<p>' + element.comm_name + element.type + 'ml * ' + element.label + '瓶' + '</p>';
										str += '	<p>' + '一提装' + 'x' + element.num + '</p>';
									}
									if(element.label == 40) {
										str += '	<p>' + element.comm_name + element.type + 'ml * ' + element.label + '瓶' + '</p>';
										str += '	<p>' + '一箱装' + 'x' + element.num + '</p>';
									}
									str += '	</div>';
									u.sum += parseInt(element.num);
								});
								str += '</div>'
								str += '<div class="distribution_num">';
								str += '<p>' + '共' + u.sum + '件' + '</p>';
								str += '</div>';
								str += '</div>';
							}
							if(u.order_status == "3") {
								str += '<div class="accomplish">'
								str += '<div class="accomplish_title">'
								str += '<div class="accomplish_title_left">'
								str += '<p>' + '订单号码：' + u.order_sn + '</p>'
								str += '<p>' + '下单时间：' + u.create_time + '</p>'
								str += '</div>'
								str += '<div class="accomplish_title_right">'
								str += '已完成'
								str += '</div>'
								str += '</div>'
								str += '<div class="accomplish_list" onclick="btn_1(this)" id="'+ u.order_sn +'">'
								u.sum = 0
								$.each(u.shoppingcart, function(index, element) {
									str += '	<div>';
									if(element.label == 4) {
										str += '	<p>' + element.comm_name + element.type + 'ml * ' + element.label + '瓶' + '</p>';
										str += '	<p>' + '一盒装' + 'x' + element.num + '</p>';
									}
									if(element.label == 6) {
										str += '	<p>' + element.comm_name + element.type + 'ml * ' + element.label + '瓶' + '</p>';
										str += '	<p>' + '一箱装' + 'x' + element.num + '</p>';
									}
									if(element.label == 10) {
										str += '	<p>' + element.comm_name + element.type + 'ml * ' + element.label + '瓶' + '</p>';
										str += '	<p>' + '一提装' + 'x' + element.num + '</p>';
									}
									if(element.label == 40) {
										str += '	<p>' + element.comm_name + element.type + 'ml * ' + element.label + '瓶' + '</p>';
										str += '	<p>' + '一箱装' + 'x' + element.num + '</p>';
									}
									str += '	</div>';
									u.sum += parseInt(element.num);
								});
								str += '</div>'
								str += '<div class="accomplish_num">'
								str += '<p>' + '共' + u.sum + '件' + '</p>'
								str += '<button onclick="cha(this)" id="'+ u.logistics +'">' + '查看物流' + '</button>'
								str += '</div>'
								str += '<div class="accomplish_express">'
								str += '<p>' + '德邦物流：' + '<span id="tar_' + u.order_id + '">' + u.logistics + '</span>' + '</p>'
								str += '<button id="copy10" data-clipboard-action="copy" data-clipboard-target="#tar_' + u.order_id +
									'">' +
									'复制' +
									'</button>'
								str += '</div>'
								str += '</div>'
							}
						});
						$(".content").html("");
						$(".content").append(str);
						
	$(".jiazai").css({
		display: "none"
	});
					}

				},
				error: function(res) {
					console.log(res)
				}
			})
		}

	}

}
//-----------------结束--------------------